<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
            <el-form-item label="姓名" prop="search">
                <el-input v-model="queryParams.name" placeholder="请输入订单编号" clearable size="small"  @keyup.enter.native="handleQuery"/>
            </el-form-item>


            <el-form-item label="时间：">
                <el-date-picker v-model="queryParams.end_month" style="width: 240px" value-format="yyyy-MM-dd" type="month"  />
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8">
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
        <el-table  v-loading="loading" :data="lists" border fit highlight-current-row>

            <el-table-column label="月份" align="center" prop="month" />
            <el-table-column label="姓名" align="center" prop="real_name"  />
            <el-table-column label="银行卡号" align="center" prop="bank_code"  />
            <el-table-column label="银行名称" align="center" prop="bank_name"  >
            <template slot-scope="{row}">
                {{ row.bank_info? row.bank_info.bank_name : "" }}
            </template>
            </el-table-column>
            <el-table-column label="可提现余额" align="center" prop="balance"  />
            <el-table-column label="提现金额" align="center" prop="extract_price"  />
            <el-table-column label="打款人" align="center" prop="operator_name"  />
            <el-table-column label="打款时间" align="center" prop="updated_time" />
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">
                <template slot-scope="{row}">
                    <el-button size="mini" v-show="row.status==0" type="text" icon="el-icon-edit" @click="handleConfirmPayment(row)">确认打款</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination
            v-show="total>0"
            :total="total"
            :page.sync="queryParams.page"
            :limit.sync="queryParams.limit"
            @pagination="getList"
        />
        <!-- 添加或修改部门对话框 -->
        <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
            <el-form ref="form" :model="form" :rules="rules" label-width="100px">
                <el-form-item label="卡号：" prop="card_no">
                    <el-input v-model="form.card_no" placeholder="请输入卡号" />
                </el-form-item>
                <el-form-item label="充值金额：" prop="con_money">
                    <el-input v-model="form.con_money" placeholder="请输入充值金额" />
                </el-form-item>
                <el-form-item label="实际金额：" prop="buy_money">
                    <el-input v-model="form.buy_money" placeholder="请输入实际充值金额" />
                </el-form-item>

            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitForm">充 &nbsp;值</el-button>
                <el-button @click="cancel">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>

import {getExtractList,confirmExtractPayment} from "@/api/grzq/extract";

export default {
    name: "master_read",
    dicts:['sys_normal_disable','sys_cost_type'],
    data() {
        return {
            // 遮罩层
            loading: true,
            // 显示搜索条件
            showSearch: true,
            // 表格数据
            lists: [],
            total: 0,
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            // 是否展开，默认全部展开
            isExpandAll: true,
            // 重新渲染表格状态
            refreshTable: true,
            // 查询参数
            queryParams: {
                search: undefined,
                page: 1,
                limit: 10,
            },
            // 表单参数
            form: {},
            // 表单校验
            rules: {
                card_no: [
                    { required: true, message: "请输入要充值的卡号", trigger: "blur" }
                ],
                con_money: [
                    { required: true, message: "请输入要充值的卡号", trigger: "blur" }
                ],
            },

        };
    },
    created() {
        this.getList();
    },
    methods: {
        /** 查询部门列表 */
        async getList() {
            let that = this;
            that.loading = true;
            const {data, status, msg} = await getExtractList(this.queryParams);
            that.lists = data.data;
            that.loading = false;
            that.total = data.total;
            that.queryParams.limit = data.per_page || 10;
        },

        // 取消按钮
        cancel() {
            this.open = false;
            this.reset();
        },
        // 表单重置
        reset() {
            this.form = {
                id: undefined,
                card_no: undefined,
                con_money: undefined,
                buy_money: undefined
            };
            this.resetForm("form");
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        /** 新增按钮操作 */
        handleAdd(row) {
            this.reset();
            this.open = true;
            this.title = "卡片充值";
        },

        /** 修改按钮操作 */
        handleConfirmPayment(row) {
            this.open = true;
            this.title = "打款确认";
            this.form = row

        },
        submitForm(){
            let that = this;
            this.$confirm('你确定打款操作吗？请谨慎操作', '确认打款',
                {confirmButtonText: '确认', cancelButtonText: '取消', type: '提示'}).then(async () => {
                // const {status, msg} = await setDel({article_id: ids, 'is_batch' : this.is_batch});
                // this.$message({
                //     message: msg,
                //     type: 'success'
                // });
                // 重新加载列表
                // this.handleFilter();

            })
                .catch(err => {
                    console.error(err);
                });
        }

    }
};
</script>
